package collection;

import java.util.*;

public class ListDemo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        //List<String> list = new LinkedList<>();

        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println("list:"+list);

        String e = list.get(2);
        System.out.println(e);

        for (int i=0;i<list.size();i++){
            e = list.get(i);
            System.out.println(e);
        }
        String old = list.set(2,"six");
        System.out.println(list);
        System.out.println(old);

        for (int i =0;i< (list.size()/2);i++){
            String str = list.get(i);
            str = list.set(list.size()-1-i,str);
            list.set(i,str);
        }

//        for (int i =0;i< (list.size()/2);i++){
//            list.set(i,list.set(list.size()-1-i,list.get(i)));
//        }

//        for (int i =0;i<list.size()/2;list.set(i,list.set(list.size()-1-i,list.get(i++))));

          //java.utio.Collections时集合的工具类
//        Collections.reverse(list);


        System.out.println(list);
    }
}
